<!-- 我的发布 -->
<template>
	<view class="my-content page">
		<!-- 导航栏 -->
		<u-tabs active-color="orange" inactive-color="orange" :list="list" :is-scroll="false" :current="current"
			@change="change"></u-tabs>
		<!--内容-->
		<view style="flex: 1;">
			<view class="merchant">
				<view class="merchant_body ">
					<view v-for="(item, index) in iconList" :key="index"
						v-if="current == 0 ? listShow.indexOf(item.auth) === -1 : authShow.indexOf(item.auth) !== -1"
						@click="skip(item)">
						<!--                TODO::u-image有阴影效果，需要去掉-->
						<!--                <u-image :lazy-load="true" :src="toImages(item.image)" height="94rpx" width="94rpx">-->
						<!--                    <u-loading slot="loading"></u-loading>-->
						<!--                </u-image>-->
						<image :src="lang == 'ru' ? toImages(item.image_ru) : toImages(item.image)"
							style="width: 94rpx;height: 94rpx;">
						</image>
						<text class="u-margin-10" style="word-break: break-all;text-align: center;">
							{{ $t(item.title) }}
							<!-- {{ $t('发布') }} -->
						</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { isBase64 } from "@/common/public";
import { IMAGE_URL } from "@/config/app";
export default {
	data() {
		return {
			show: true,
			list: [
				{
					name: this.$t('推广')
				},
				{
					name: this.$t('订单')
				},
			],
			current: 0,
			lang: this.$i18n.locale,
			iconList: [],
			listShow: ['library1', 'news1'],
			authShow: [
				'goods2', 'transport2', 'professional2', 'crossborder2'
			],
		};
	},
	onReady() {
		uni.setNavigationBarTitle({
			title: this.$t("我的发布")
		})
	},
	computed: {
		toImages() {
			return (src) => {
				return isBase64(src) ? src : IMAGE_URL + src
			}
		},
	},
	onLoad() {
		this.getIconList()
	},
	onShow() {
		if(uni.getStorageSync('off')==false){
			this.list = [
				{
					name: this.$t('推广')
				},
				{
					name: this.$t('订单')
				},
			]
		}else{
			this.list = [
				{
					name: this.$t('推广')
				},
				{
					name: this.$t('竞标')
				},
			]
		}
	},
	methods: {
		skip(val) {
			// console.log(val);
			const auth = val.auth.substr(0,val.auth.length-1)
			console.log(auth);
			this.$u.route({
				url: 'pages/user/issue/delight',
				params: {
					name:auth,
					type:Number(val.type)
				}
			})
		},
		// tabs
		change(index) {
			this.current = index
			this.show = !this.show
			this.getIconList()
		},
		async getIconList() {
			const that = this
			await that.$u.api.user.getUserAuthIcon({user_id:uni.getStorageSync('user_id')}).then(res => {
				if (this.current == 0) {
					that.iconList = res[1]
				} else {
					that.iconList = res[2]
				}
				console.log('getHomeIcon-login', that.iconList)
			})
		},

	},

}
</script>

<style lang="scss" scoped>
.page {
	display: flex;
	flex-direction: column;
}

.merchant {
	height: 100%;
	display: flex;
	flex-direction: column;
	background-color: #F7F7F7;
	padding-top: 40rpx;

	.merchant_title {
		font-size: 28rpx;
		font-weight: 600;
		color: rgba(0, 0, 0, 0.88);
		line-height: 38rpx;
		padding: 55.81rpx 0 55.81rpx 55.81rpx;
	}

	//内容

	.merchant_body {
		display: grid;
		grid-template-columns: repeat(2, 295rpx);
		justify-content: space-around;
		background-color: #F7F7F7;

		view {
			padding-top: 20rpx;
			width: 295rpx;
			margin-bottom: 26.16rpx;
			min-height: 197rpx;
			background: #FFFFFF;
			box-shadow: 3rpx 3rpx 7rpx 0rpx rgba(224, 224, 224, 0.5);
			border-radius: 14rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			//   justify-content: center;

			text {
				text-align: center;
			}
		}
	}
}
</style>
